<?php
App::loadLib ( "JieKu.FrameWork.Controller" );
class schooltypes extends Controller{
	function __construct() {
	
	}
	function item() {
		$view = $this->jieku->getView ();
		$db = $this->jieku->getDB ();
		
	}
	function addtype(){
		$view = $this->jieku->getView ();
		$db = $this->jieku->getDB ();
		$db->query(JDBTool::select( array("id","title"),
									array("px_schooltype"),
									"pid=0 and
									 state=1"));
		$pList=$db->getAll();
		array_unshift($pList,array("id"=>0,"title"=>"父节点"));
		$view->add("pList",$pList);							
	}
	function add(){
		$db = $this->jieku->getDB ();
		$schooltype=$this->jieku->var['schooltype'];
		$schooltype['state']=1;
		$db->exec(JDBTool::insert("px_schooltype",$schooltype));
		$this->actionForward("addtype");
	}
	function getCtypes(){
		$db = $this->jieku->getDB ();
		$view = $this->jieku->getView ();
		$pids=$this->jieku->var['pids'];
		$db->query(JDBTool::select(array('id','title','pid'),
									array('px_schooltype'),
									"pid in($pids)"));
	
		$view->add("cList",$db->getAll());
	}
}

?>
